package bairui.international.weixin.portal.miniapp.controller.barter.order;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lianjing.sh.spring.web.controller.base.action.Action;
import com.lianjing.sh.spring.web.controller.enhance.output.FomatOutput;

import bairui.international.model.domain.jpa.TB_ProductOrder;
import bairui.international.service.Service_ProductOrder;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 *
 * 支付
 *
 * @generated
 * 
 * @see STest_C_Barter_Order_Pay_Get 测试
 *
 */
@Controller
public class C_Barter_Order_Pay_Get
 extends SC_Barter_Order_Pay_Get 
{
	
	@Autowired private Service_ProductOrder service_ProductOrder;
	
	/**
	 * Get请求
	 */
	@Action(Get.class)
	@PostMapping(Get.RequestMappingValue)
	public @FomatOutput @ResponseBody Object get(
		ModelMap map, HttpServletRequest request, 
		@PathVariable(name=Get.PathVariableName.Id) long id,
		@RequestParam String skey, 
		@RequestBody Input input
	) throws Exception {
		TB_ProductOrder order = service_ProductOrder.gradeOrderPay(
				skey,
				id, 
				input.getAddress().getUsername(),
				input.getAddress().getPhone(),
				input.getAddress().getArea(),
				input.getAddress().getDetailAddress(),
				input.getAddress().getTownId(),
				input.getComment()
			);
		return order.getId();
	}
	
	@ToString
	private static class Input {
		@Getter @Setter private Address address;
		@Getter @Setter private String comment;
	}
	
	@ToString
	private static class Address {
		@Getter @Setter private String username;
		@Getter @Setter private String phone;
		@Getter @Setter private String area;
		@Getter @Setter private String detailAddress;
		@Getter @Setter private Long townId;
	}

}
